package com.plum.admin.common.util;

import lombok.experimental.UtilityClass;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * TODO
 *
 * @author 子丶沫
 * @version 1.0
 * @date 2021/9/2 14:55
 */
@UtilityClass
public class PasswordUtil {
    private static BCryptPasswordEncoder passwordEncoder=null;

    static {
        passwordEncoder=new BCryptPasswordEncoder();
    }
    public boolean validaPassword(String newPass,String passwordEncodeOldPass){
        return passwordEncoder.matches(newPass,passwordEncodeOldPass);
    }
    public String encodePassword(String password){
        return passwordEncoder.encode(password);
    }

    public static void main(String[] args) {
        System.out.println(PasswordUtil.encodePassword("12345678"));
    }
}
